<template>
  <demoBlock title="可展开" padding>
    <vcu-table :columns="columns" :datas="data">
      <template #expandedRowRender="{ record }">
        <p style="margin: 0">
          {{ record.description }}
        </p>
      </template>
    </vcu-table>
  </demoBlock>
</template>

<script>
import { defineComponent, ref } from "vue";
const columns = [
  {
    title: "姓名",
    dataIndex: "name",
    key: "name",
  },
  {
    title: "年龄",
    dataIndex: "age",
    key: "age",
  },
  {
    title: "地址",
    dataIndex: "address",
    key: "address",
  },
  {
    title: "标签",
    key: "tags",
    dataIndex: "tags",
  },
];

const data = [
  {
    key: "1",
    name: "张三",
    age: 32,
    address: "火星",
    tags: "漂亮的",
    description: "情浓时，海誓山盟;情淡时，形同陌路.",
  },
  {
    key: "2",
    name: "李四",
    age: 42,
    address: "地球",
    tags: "失败者",
    description: "这城市风很大，孤独的人总是晚回家.",
  },
  {
    key: "3",
    name: "王五",
    age: 32,
    address: "月亮",
    tags: "冰冷的",
    description: "那些不经意想起的，总是记忆里最深刻的.",
  },
];
export default defineComponent({
  setup() {
    const handleAdd = (record) => {
      console.info(record);
    };
    return {
      data,
      columns,
      handleAdd,
    };
  },
});
</script>
